<template>
	<tui-list-cell lineLeft="0" padding="26rpx 0" v-for="(item,index) in dataList" :key="index">
		<view class="tui-item-box">
			<view class="tui-msg-box">
				<image v-if="!item.avatar"
					src="https://dn-coding-net-production-pp.codehub.cn/270e73de-2548-406b-9e1c-c0c8481dff90.png"
					class="tui-msg-pic" mode="widthFix"></image>
				<image v-else :src="ossUrl + item.avatar" class="tui-msg-pic"></image>
				<view class="tui-msg-item">
					<view class="tui-msg-name">{{item.nickname}}</view>
					<view class="tui-msg-content">{{item.content}}</view>
				</view>
			</view>
			<view class="tui-msg-right">
				<view class="tui-msg-time">{{getDate(item.commentTime)}}</view>
			</view>
		</view>
	</tui-list-cell>
</template>

<script>
	export default {
		name: 'CommentItem',
		emits: ['clickDetail'],
		props: {
			// 数据列表
			dataList: {
				type: Array,
				default: []
			},
			//oss
			ossUrl:{
				type: String,
				default:''
			}
		},
		data() {
			return {
				
			}
		},
		computed: {
		    
		},
		methods: {
			getDate(commentTime){
				return commentTime.substring(0, 10);
			}
		}
	}
</script>

<style>
	/* 评论列表 */
	.tui-item-box {
		width: 100%;
		display: flex;
		align-items: center;
	}

	.tui-msg-box {
		width: 50%;
		display: flex;
		align-items: center;
	}

	.tui-msg-pic {
		width: 100rpx;
		height: 100rpx;
		border: 3rpx solid #2FD7D3;
		border-radius: 50%;
		display: block;
		margin-right: 24rpx;
		flex-shrink: 0;
	}

	.tui-msg-item {
		flex: 1;
		min-height: 80rpx;
		overflow: hidden;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}

	.tui-msg-name {
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
		font-size: 34rpx;
		line-height: 1;
		color: #262b3a;
	}

	.tui-msg-content {
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
		font-size: 26rpx;
		line-height: 1;
		color: #9397a4;
	}

	.tui-msg-right {
		flex: 1;
		height: 88rpx;
		margin-left: auto;
		text-align: right;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		align-items: flex-end;
	}

	.tui-msg-time {
		width: 100%;
		font-size: 24rpx;
		line-height: 24rpx;
		color: #9397a4;
	}
</style>
